#include<iostream>
#include<algorithm>
#include<cstring>

using namespace std ;

const int maxn = 510 ;  //最大点数
const int maxm = 10010 ;    //最大边数

//这个算法只用存边，不用存顶点
struct Edge{
    int a ; //起点
    int b ;
    int w ; //这条边的权值
}edges[maxm];   //这个数组用来存放所有的边

int n , m , k; //顶点数和边数, k是最多允许几条边
int dist[maxn]; //  每个点到原点的距离
int backup[maxn] ;  //定义一个和dist一模一样的数组，用来备份dist

void bellman_ford() {
    memset(dist , 0x3f , sizeof dist) ;
    dist[1] = 0 ;

    for (int i = 0; i < k; ++i) {
        memcpy(backup , dist , sizeof dist );
        for(int j = 0 ; j < m ; j++){
            int a = edges[j].a;
            int b = edges[j].b;
            int w = edges[j].w;
            dist[b] = min(backup[a] + w , dist[b]);
        }
    }

}

int main() {

    scanf("%d%d%d" , &n , &m , &k);

    for (int i = 0; i < m; ++i) {
        int a, b , c;
        scanf("%d%d%d" , &a , &b , &c);
        edges[i] = {a , b , c};
    }

    bellman_ford();

    if(dist[n] > 0x3f3f3f3f / 2){
        puts("impossible");
    }else{
        printf("%d\n" , dist[n]);
    }

    return 0 ;
}